Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-xray-sdk-postgres

Package Overview
Dependencies
Maintainers
13
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-xray-sdk-postgres

AWS X-Ray Patcher for Postgres (Javascript)

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
314K
decreased by-0.3%
Maintainers
13
Weekly downloads
 
Created
Source

Requirements

AWS X-Ray SDK Core Postgres 6.1.0 or greater

AWS X-Ray and Postgres

The AWS X-Ray Postgres package automatically records query information and request and response data. Simply patch the Postgres package via capturePostgres as shown below.

The AWS X-Ray SDK Core has two modes - manual and automatic. Automatic mode uses the Continuation Local Storage package (CLS) and automatically tracks the current segment and subsegment. This is the default mode. Manual mode requires that you pass around the segment reference. See the examples below.

Environment variables

POSTGRES_DATABASE_VERSION        Sets additional data for the sql subsegment.
POSTGRES_DRIVER_VERSION          Sets additional data for the sql subsegment.

Automatic mode example

var AWSXRay = require('aws-xray-sdk-core');
var capturePostgres = require('aws-xray-sdk-postgres');

var pg = capturePostgres(require('pg'));

...

var client = new pg.Client();

client.connect(function (err) {
  ...

  client.query({name: 'moop', text: 'SELECT $1::text as name'}, ['brianc'], function (err, result) {
    //Automatically captures query information and errors (if any)
  });
});

...

var pool = new pg.Pool(config);
pool.connect(function(err, client, done) {
  if(err) {
    return console.error('error fetching client from pool', err);
  }
  var query = client.query('SELECT * FROM mytable', function(err, result) {
    //Automatically captures query information and errors (if any)
  });
});

Manual mode example

var AWSXRay = require('aws-xray-sdk-core');
var capturePostgres = require('aws-xray-sdk-postgres');

var pg = capturePostgres(require('pg'));

...

var client = new pg.Client();

client.connect(function (err) {
  ...

  client.query({name: 'moop', text: 'SELECT $1::text as name'}, ['mcmuls'], function (err, result) {
    //Automatically captures query information and errors (if any)
  });
});

...

var pool = new pg.Pool(config);
pool.connect(function(err, client, done) {
  if(err) {
    return console.error('error fetching client from pool', err);
  }
  var query = client.query('SELECT * FROM mytable', function(err, result) {
    //Automatically captures query information and errors (if any)
  }, segment));
};

Keywords

FAQs

Package last updated on 11 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc